﻿using Microsoft.Xna.Framework;
using RaptorEngine;
using RaptorEngine.Components;

namespace OilRigSumoWrestlers.Controllables
{
	class ParticleSprayer : Controllable
	{
		private Vector3 _position, _velocity;
		private int _particlesPerSecond;
		public ParticleSprayer(Entity entity, Vector3 position, Vector3 velocity, int particlesPerSecond) : base(entity)
		{
			_position = position;
			_velocity = velocity;
			_particlesPerSecond = particlesPerSecond;
		}

		public override void Update(GameTime gameTime)
		{
			if (Entity.HasComponent(ComponentType.Particle))
			{
				ParticleComp part = (ParticleComp)Entity.GetComponent(ComponentType.Particle);
				float dT = gameTime.ElapsedGameTime.Milliseconds;
				int particles = (int)(dT / (1000 / _particlesPerSecond));
				for (int i = 0; i < particles; i++)
				{
					part.AddParticles(_position, _velocity);
				}
			}
		}
	}
}
